﻿using Infrastructure.Pub;
using Infrastructure.Tool;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using DormMS.Model;

namespace WeChat
{
    public class AuthorizeFilterAttribute : ActionFilterAttribute
    {
       
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //登录验证
            //UserInfoService userservice = new UserInfoService();
            //var user = userservice.GetCacheUser();
            string uniqueKey = PubGet.GetMemberKey;
            if (!uniqueKey.IsNullOrEmpty())
            {
                var user = CacheManager<Member>.GetInstance()[uniqueKey];

                if (user == null || user.Id <= 0)
                {

                    filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.NotAcceptable;
                    //return;
                }   
            }
            else
            {
                filterContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.NotAcceptable;
                //return;
            }

        }
    }
}